/*
 * gnc_supple.c
 *
 *  Created on: 2023年3月28日
 *      Author: Lw
 */
#include "gnc_addit.h"
#include "camera_process.h"
#include "pl_comm.h"
#include "tele_data_transfer.h"

extern CameraSetting	g_sCamera1Setting;
extern CameraSetting   g_sCamera2Setting;
extern S_tEquipmentStatus g_tEquipmentStatus;      /* 设备的状态信息结构体 */

void gncAdditInit(void)
{
	s_Addit1Data.State = WAIT_PHOT;
}

void gncAdditProcess(void)
{
    switch(s_Addit1Data.State)
    {
        case WAIT_PHOT:
        break;

        case BEGIN_PHOT:
        	s_Addit1Data.AdditNumCount = 2;
        	s_Addit1Data.AdditTotalCount = 1;
        	s_Addit1Data.PhotoFlag = 0;
        	s_Addit1Data.ShootMomentS = g_sCamera1Setting.beginShootTimeS;
        	s_Addit1Data.ShootMomentMs = g_sCamera1Setting.beginShootTimeMs;
        	s_Addit1Data.ExpTimeMs = (g_tEquipmentStatus.uiCamera_1_ExposureTime/1000);
        	s_Addit1Data.Gain = g_tEquipmentStatus.ucCamera_1_GainRGB;
        	s_Addit1Data.Mode = g_tEquipmentStatus.ucCamera_1_WorkMode;
        	WriteAdditData(CAMERA_ONE,s_Addit1Data.AdditTotalCount,&s_Addit1Data);
        	s_Addit1Data.RecvGncRelaxLen = 0;
        	s_Addit1Data.State = BURST_PHOT;
        break;

        case BURST_PHOT:
        	if(s_Addit1Data.RecvGncRelaxLen == ADDITDATALEN && s_Addit1Data.AdditNumCount <= s_Addit1Data.AdditNum)
        	{
        		s_Addit1Data.AdditNumCount++;
        		s_Addit1Data.AdditTotalCount++;
            	WriteAdditData(CAMERA_ONE,s_Addit1Data.AdditTotalCount,&s_Addit1Data);
            	s_Addit1Data.RecvGncRelaxLen = 0;
        	}
        	if(s_Addit1Data.AdditNumCount > s_Addit1Data.AdditNum)
        	{
        		s_Addit1Data.State = WAIT_RELEASE;
        	}
        break;

        case WAIT_RELEASE:
        	if(s_Addit1Data.PhotoFlag == 1)
        	{
        		s_Addit1Data.PhotoFlag = 0;
        		s_Addit1Data.AdditNumCount = 1;
        		s_Addit1Data.AdditNumCount++;
        		s_Addit1Data.AdditTotalCount++;
            	WriteAdditData(CAMERA_ONE,s_Addit1Data.AdditTotalCount,&s_Addit1Data);
            	s_Addit1Data.RecvGncRelaxLen = 0;
            	s_Addit1Data.State = BURST_PHOT;
        	}
        break;

        default:
        break;
    }

    switch(s_Addit2Data.State)
    {
        case WAIT_PHOT:
        break;

        case BEGIN_PHOT:
        	s_Addit2Data.AdditNumCount = 2;
        	s_Addit2Data.AdditTotalCount = 1;
        	s_Addit2Data.PhotoFlag = 0;
        	s_Addit2Data.ShootMomentS = g_sCamera2Setting.beginShootTimeS;
        	s_Addit2Data.ShootMomentMs = g_sCamera2Setting.beginShootTimeMs;
        	s_Addit2Data.ExpTimeMs = (g_tEquipmentStatus.uiCamera_2_ExposureTime/1000);
        	s_Addit2Data.Gain = g_tEquipmentStatus.ucCamera_2_GainRGB;
        	s_Addit2Data.Mode = g_tEquipmentStatus.ucCamera_2_WorkMode;
        	WriteAdditData(CAMERA_TWO,s_Addit2Data.AdditTotalCount,&s_Addit2Data);
        	s_Addit2Data.RecvGncRelaxLen = 0;
        	s_Addit2Data.State = BURST_PHOT;
        break;

        case BURST_PHOT:
        	if(s_Addit2Data.RecvGncRelaxLen == ADDITDATALEN && s_Addit2Data.AdditNumCount <= s_Addit2Data.AdditNum)
        	{
        		s_Addit2Data.AdditNumCount++;
        		s_Addit2Data.AdditTotalCount++;
            	WriteAdditData(CAMERA_TWO,s_Addit2Data.AdditTotalCount,&s_Addit2Data);
            	s_Addit2Data.RecvGncRelaxLen = 0;
        	}
        	if(s_Addit2Data.AdditNumCount > s_Addit2Data.AdditNum)
        	{
        		s_Addit2Data.State = WAIT_RELEASE;
        	}
        break;

        case WAIT_RELEASE:
        	if(s_Addit2Data.PhotoFlag == 1)
        	{
        		s_Addit2Data.PhotoFlag = 0;
        		s_Addit2Data.AdditNumCount = 1;
        		s_Addit2Data.AdditNumCount++;
        		s_Addit2Data.AdditTotalCount++;
            	WriteAdditData(CAMERA_TWO,s_Addit2Data.AdditTotalCount,&s_Addit2Data);
            	s_Addit2Data.RecvGncRelaxLen = 0;
            	s_Addit2Data.State = BURST_PHOT;
        	}
        break;

        case WRITE_ADDIT:

        break;

        default:
        break;
    }



}
